<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.carcenter.pojo.CarUserinfo"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.carcenter.service.MessageService"%>
<%@page import="com.carcenter.pojo.CarReMessage"%>
<%@page import="com.carcenter.service.UserinfoService"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>全国最大的汽车网</title>
	<link rel="stylesheet" type="text/css" href="css/style_new.css" />
	<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
	
	<script src="js/prototype.js" type="text/javascript"></script>
	<script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
	<script src="js/lightbox.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/java.js"></script>
    <script>
    function showhf(fid)
    {
        document.getElementById(fid).style.display='';
    }
    
    </script>
</head>
<body>
<div id="wrap">

       <s:include value="../header.jsp"></s:include>
       
       
       <div class="center_content">
       	<div class="left_content">
        	<div class="crumb_nav">
            	首页  &gt;&gt; 汽车详细
            </div>
            <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>汽车详细</div>
        
        	<div class="feat_prod_box_details">
            
            	<div class="prod_img"><img src="upload/car/${carinfo.cid}${carinfo.pictureurl}" width="100" height="100" alt="" title="" border="0" />
                <br /><br />
                <a href="upload/car/${carinfo.cid}${carinfo.pictureurl}" rel="lightbox"><img src="images/zoom.gif" alt="" title="" border="0" /></a>
                </div>
                
                <div class="prod_det_box">
                	<div class="box_top"></div>
                    <div class="box_center">
                    <div class="prod_title"><strong>详细信息</strong></div>
                    <p class="details"></p>
                    <div class="price"><strong>类型:</strong> <span class="red"><s:property value="carinfo.type" /></span></div>
                    <div class="price"><strong>品牌:</strong> <span class="red"><s:property value="carinfo.brand" /></span></div>
                    <%
                    boolean isdis = false;
                    Integer currId = (Integer)session.getAttribute("uid");
                	UserinfoService userinfoService = new UserinfoService();
                	CarUserinfo currUser = userinfoService.getUserById(currId);
                	Date birdate = currUser.getBirthday();
                	SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
                	String s1 = sdf.format(birdate);
                	String s2 = sdf.format(new Date());
                	if(s2.equals(s1)){
                		isdis = true;
                	}
                    %>
                    <div class="price"><strong>价格:</strong> <span class="red"><span <%if(isdis){ %> style="text-decoration:line-through" <%} %>><s:property value="carinfo.price" /></span>
                     <%if(isdis){ %><span> VIP折扣价：<s:property value="carinfo.price * carinfo.discount" /></span><%} %>
                    </span></div>
                    <div class="price"><strong>原产地:</strong> <span class="red"><s:property value="carinfo.origin" /></span></div>
                    <div class="price"><strong>二手车:</strong> <span class="red"><s:property value="carinfo.isused" /></span></div>
                    <div class="price"><strong>车龄:</strong> <span class="red"><s:property value="carinfo.carage" /></span></div>
                    <div class="price"><strong>里程:</strong> <span class="red"><s:property value="carinfo.mileage" /></span></div>
                    <div class="price"><strong>颜色:</strong> 
                    <span class="colors"><img src="images/color1.gif" alt="" title="" border="0" /></span>
                    <span class="colors"><img src="images/color2.gif" alt="" title="" border="0" /></span>
                    <span class="colors"><img src="images/color3.gif" alt="" title="" border="0" /></span>                    </div>
                    <div class="clear"></div>
                    </div>
                    
                    <div class="box_bottom"></div>
                </div>    
            <div class="clear"></div>
            </div>	
            
              
            <div id="demo" class="demolayout">
                             
              	<div class="contact_form">
                <div class="form_subtitle">你说我说</div>          
                    
                    <div>
                    <label class="contact"><strong>免责声明:</strong></label>
                    本文仅代表作者个人观点，与本站无关。其原创性以及文中陈述文字和内容未经本站证实，对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺，请读者仅作参考，并请自行核实相关内容。
                    </div>
	  <div class="clear"></div>
	  <br />
	  <hr />
	  
	 				 <%
						Integer currUserId = (Integer)session.getAttribute("uid");
						UserinfoService serv = new UserinfoService();
						boolean flag = serv.isManager(currUserId);
						
					%>
	  	
	  	<s:iterator value="messageList" var="mess" status="stat">

 					<div class="form_row">
                    <label class="contact"><strong><s:property value="#mess.username" />:</strong></label>
                 	<s:property value="#mess.content" />
                    <br />
                    <div style="float: right;color: black;" >
                    <a href="javascript:void(0)" onclick="showhf('id${stat.count}')"><span style="color:black;">回复</span></a>
                    <%if(flag){ %>
                    <s:a href="delMessage.action?messageID=%{#mess.mid}&carinfoID=%{carinfoID}"><span style="color:black;">删除</span></s:a>
                    <%} %>
                    </div>
                    
                    <div id="id${stat.count}" style="display: none;" >
                    <s:form action="addReMessage.action" name="formzi%{#stat.count}">
                    <div class="form_row">
                    <label class="contact"><strong>回复<s:property value="#mess.username" />:</strong></label>
                    <textarea name="remessage.reContent" class="contact_textarea" onkeyup='value=value.substr(0,100);this.nextSibling.innerHTML=value.length+"/100";' ></textarea>
                    <s:hidden name="remessage.mid" value="%{#mess.mid}"></s:hidden>
                    <s:hidden name="carinfoID" ></s:hidden>
                    </div>

                    <div class="form_row">
                    <a href="javascript:document.formzi${stat.count}.submit();" class="contact">确认</a>
                    </div>
                    </s:form>
                    </div>  
                    
                    
                    
                    <br /> <br />
					
					<s:set id="messid" value="#mess.mid" scope="request"></s:set>
					<%
						Integer messid = (Integer)request.getAttribute("messid");
						if(messid != null){
							MessageService messService = new MessageService();
							List<CarReMessage> remessList = messService.getAllReMessage(messid);
							request.setAttribute("remessList",remessList);
						}
					%>
					
					<s:iterator value="#request.remessList" var="remess" status="sta">
					<div style="width: 250px;float: right;padding-bottom: 15px;">
					<label class="contact"><strong><s:property value="#remess.reUsername" />:</strong></label>
					<s:property value="#remess.reContent" />
					<br />
                    <div style="float: right;color: black;" >
                     <%if(flag){ %>
                    <s:a href="delReMessage.action?remessageID=%{#remess.rid}&carinfoID=%{carinfoID}"><span style="color:black;">删除</span></s:a>
                    <%} %>
                    </div>
					</div>
					</s:iterator>
					
                    </div>
                    
                    
              </s:iterator>      

<s:form action="addMessage.action" name="formpl">
                    <div class="form_row">
                    <label class="contact"><strong>评论:</strong></label>
                    <textarea name="message.content" class="contact_textarea" onkeyup='value=value.substr(0,250);this.nextSibling.innerHTML=value.length+"/250";' ></textarea>
                   	<s:hidden name="message.cid" value="%{carinfo.cid}"></s:hidden>
                   	<s:hidden name="carinfoID" ></s:hidden>
                    </div>

                    <div class="form_row">
                    <a href="javascript:document.formpl.submit();" class="contact">确认</a>  </div> 
</s:form>                    
                         
                </div>  
			</div>
            
        <div class="clear"></div>
        </div><!--end of left content-->
        
        <div class="right_content">
        
                <s:include value="../cart.jsp"></s:include>
	        	<s:include value="../aboutour.jsp"></s:include>
             	<s:include value="../right1.jsp"></s:include>
          
        
        </div><!--end of right content-->
        
        
       
       
       <div class="clear"></div>
       </div><!--end of center content-->
       
	 <s:include value="../footer.jsp"></s:include>

</div>

</body>
</html>

